using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

namespace EntLibContrib.Validation.Validators
{
    public class CompositeRulesetValidatorAttribute : ValidatorAttribute
    {
        private string targetRulesets;
        private ValidationSpecificationSource source;
        private string configurationSourceName;

        public string TargetRulesets
        {
            get { return targetRulesets; }
            set { targetRulesets = value; }
        }

        public ValidationSpecificationSource Source
        {
            get { return source; }
            set { source = value; }
        }

        public string ConfigurationSourceName
        {
            get { return configurationSourceName; }
            set { configurationSourceName = value; }
        }

        protected override Validator DoCreateValidator(Type targetType)
        {
            return new CompositeRulesetValidator(
                targetType, 
                CompositeRulesetValidator.GetTargetRulesets(TargetRulesets), 
                Source,
                ConfigurationSourceName);
        }
    }
}
